package spring.cloud.tasks.executor.listener.analyse;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import spring.cloud.tasks.executor.listener.ListenerHolder;
import spring.cloud.tasks.executor.node.TaskNodePaths;
import spring.cloud.tasks.executor.task.TaskExecutor;

@Slf4j
@Setter
@Getter
public class AnalyseResetListenerHolder extends ListenerHolder {
    public boolean isShutdown = false;

    public AnalyseResetListenerHolder(TaskExecutor taskExecutor) {
        super(taskExecutor);
    }

    @Override
    public void start() {
        nodeCacheOrTreeCacheManager.addTreeCacheListener(TaskNodePaths.getTaskNodePath(taskId, AnalyseNode.analyse_reset), 0, new AnalyseResetListener(this));
    }

    @Override
    public void stop() {
        super.stop();
        isShutdown = true;
        nodeCacheOrTreeCacheManager.closeTreeCache(TaskNodePaths.getTaskNodePath(taskId, AnalyseNode.analyse_reset), 0);
    }

}
